import Vue from 'vue'
import VueRouter from 'vue-router'

// 映射懒加载
const home = () => import("../views/home/Home.vue")
const cart = () => import("../views/cart/Cart.vue")
const category = () => import("../views/category/Category.vue")
const profile = () => import("../views/profile/Profile.vue")

// 1.安装插件
Vue.use(VueRouter)

// 2.创建路由对象
const routes = [
  {
    path: '',
    redirect: '/home'
  },
  {
    path: '/home',
    component:home
  },
  {
    path: '/cart',
    component:cart
  },
  {
    path: '/category',
    component:category
  },
  {
    path: '/profile',
    component:profile
  }
]

const router = new VueRouter({
  routes,
  mode:"history"
})

// 3.导出路由
export default router
